<?php

/*
 * Контроллер отвечающий за авторизацию юзера
 */

class Control_AuthAction extends Control_Action{
    public function setArgs($args = null) {
        if (null != $args){
            $this->args = $args;
        }
        return $this;
    }
    public function setView($view) {
        if (null != $view){
            $this->view = $view;
        }
        return $this;
    }
    public function run(){
        $t = Model_File::getSTime();
        
        $userMapper = Model_UserMapper::authUser($this->args);
        if(!is_array($userMapper)){
            header('location: http://petrovland.site50.net/');
        } else {
            $_SESSION['authUserId'] = $userMapper['id'];
            $_SESSION['authUserName'] = $userMapper['name'];
            $_SESSION['time'] = Model_File::getTime($t);
            $_SESSION['memory'] = memory_get_usage();
            header('location: http://petrovland.site50.net/?control=user&'.$userMapper['id']);
   
        }
    }
}
